
package com.henme.crm.util.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author suwuqiang 2011-8-18
 */
//@ThreadSafe
public class DynamicDataSource extends AbstractRoutingDataSource {

    /*
     * 返回RUTE后的数据源名称key
     *
     * @see
     * org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource#
     * determineCurrentLookupKey()
     */
    @Override
    protected Object determineCurrentLookupKey() {
        // service层显式调用MyBatisDataSourceContextHolder.setDataSourceType方法，决定当前线程所需要的dataSource
        return MyBatisDataSourceContextHolder.getDataSourceType();
    }

}
